package starcoast.bocai.com.starcoast.view;


import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.Toast;

import starcoast.bocai.com.starcoast.R;
import starcoast.bocai.com.starcoast.adapter.TextAdapter;


public class ViewRight extends RelativeLayout implements ViewBaseAction{

	private ListView mListView;
	private String[] items = new String[] { };//显示字段
	private OnSelectListener mOnSelectListener;
	private TextAdapter adapter;
	private String mDistance;
	private String showText = "item1";
	private Context mContext;

	public String getShowText() {
		return showText;
	}

	public ViewRight(Context context,String[] items) {
		super(context);
		this.items = items;
		init(context);
	}
	private void init(Context context) {
		mContext = context;
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		inflater.inflate(R.layout.view_distance, this, true);
		mListView = (ListView) findViewById(R.id.listView);
		adapter = new TextAdapter(context, items, R.color.color_white, R.color.color_white);
		adapter.setTextSize(17);
		mListView.setAdapter(adapter);
		adapter.setOnItemClickListener(new TextAdapter.OnItemClickListener() {

			@Override
			public void onItemClick(View view, int position) {

				if (mOnSelectListener != null) {
					showText = items[position];
					mOnSelectListener.getValue(position+"", items[position]);
				}
			}
		});
	}
    public void setData(String[] items){
		this.items = items;
		adapter.notifyDataSetChanged();
	}
	public void setOnSelectListener(OnSelectListener onSelectListener) {
		mOnSelectListener = onSelectListener;
	}

	public interface OnSelectListener {
		public void getValue(String distance, String showText);
	}

	@Override
	public void hide() {
		
	}

	@Override
	public void show() {
		
	}

}
